import Immutable from 'immutable';
import Cursor from 'immutable/contrib/cursor';

import {expect} from 'chai';
describe('cursor', ()=>{
	it("first", ()=>{
		var data = Immutable.fromJS({ a: { b: { c: 1 } } });
		var cursor = Cursor.from(data, ['a', 'b'], (newData, var1, var2) => {
			data = newData;
		});

		cursor.get('c'); // 1
		cursor = cursor.update('c', x => x + 1);
		cursor.get('c'); // 2

		// ... back to data ...
		expect(data.getIn(['a', 'b', 'c'])).to.equal(2)

		cursor = cursor.update('c', x=> x+1);
		expect(data.getIn(['a', 'b', 'c'])).to.equal(3)

		data.update(['a', 'b', 'c'], value => 5);

		console.log(cursor.get('c'))
	})
})